home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / SWDOS12 / LOGDRIVE.ASM < prev    next >
Assembly Source File  |  1992-08-26  |  6KB  |  189 lines

  1. Page 60,132
  2.  
  3. Comment |
  4. ******************************************************************
  5.  
  6. File:       LOGDRIVE.ASM
  7. Author:     Allen L. Wyatt
  8. Date:       7/26/92
  9. Assembler:  MASM 6.0
  10.  
  11. Purpose:    Illustrate use of IOCTL function 0Eh and 0Fh.  Always
  12.             forces the desired drive into the logical mapping so
  13.             there is no prompt for "Insert disk for drive ..."
  14.  
  15. Format:     LOGDRIVE
  16.  
  17. ******************************************************************|
  18.  
  19.             .MODEL  small
  20.             .STACK                      ;Default 1Kb stack is OK
  21.             .DATA
  22. Msg1        DB      'Press any key to see directory of drive A:',13,10,0
  23. Msg2        DB      'Press any key to see directory of drive B:',13,10,0
  24. Msg3        DB      '*** Drive mapping techniques not being used ***',13,10,0
  25. Msg4        DB      '*** Drive mapping techniques being used ***',13,10,0
  26.  
  27. OneDrive    DB      'There is only one logical drive assigned to this device'
  28. CRLF        DB      13,10,0
  29.  
  30. EMsg1       DB      'Could not use IOCTL function 0Eh',0
  31.  
  32. DirA        DB      'A:\*.*',0
  33. DirB        DB      'B:\*.*',0
  34. NoMore      DB      'No more files on drive',13,10,13,10,0
  35.  
  36.             .CODE
  37.             .STARTUP
  38. LogDrive    PROC
  39.  
  40. ; Check if running on system where A/B is one drive
  41.  
  42.             MOV     AH,44h              ;IOCTL
  43.             MOV     AL,0Eh              ;Get logical device map
  44.             MOV     BL,1                ;Drive A:
  45.             INT     21h
  46.             JC      Error1
  47.             CMP     AL,0
  48.             JNE     DoIt                ;Logical drives present, continue
  49.             MOV     SI,OFFSET OneDrive
  50.             CALL    PrtString
  51.             JMP     AllDone
  52.  
  53. Doit:       CALL    Cls
  54.  
  55. ; First, give an example of what normally happens
  56.  
  57.             MOV     SI,OFFSET Msg3
  58.             CALL    PrtString
  59.             MOV     SI,OFFSET Msg1
  60.             CALL    KeyMsg              ;Display message, wait for keypress
  61.             MOV     DX,OFFSET DirA
  62.             CALL    ShowDir
  63.  
  64.             MOV     SI,OFFSET Msg2
  65.             CALL    KeyMsg              ;Display message, wait for keypress
  66.             MOV     DX,OFFSET DirB
  67.             CALL    ShowDir
  68.  
  69. ; Now give an example of what can happen
  70.  
  71.             MOV     SI,OFFSET Msg4
  72.             CALL    PrtString
  73.             MOV     SI,OFFSET Msg1
  74.             CALL    KeyMsg              ;Display message, wait for keypress
  75.             CALL    MakeItA
  76.             MOV     DX,OFFSET DirA
  77.             CALL    ShowDir
  78.  
  79.             MOV     SI,OFFSET Msg2
  80.             CALL    KeyMsg              ;Display message, wait for keypress
  81.             CALL    MakeItB
  82.             MOV     DX,OFFSET DirB
  83.             CALL    ShowDir
  84.             JMP     AllDone
  85.  
  86. Error1:     MOV     SI,OFFSET EMsg1
  87.             CALL    PrtString
  88. AllDone:    .EXIT
  89. LogDrive    ENDP
  90.  
  91.  
  92.  ; The following routine clears the screen and homes the cursor
  93.  
  94. Cls         PROC    USES AX BX CX DX
  95.             MOV     AH,6                ;Scroll window up
  96.             MOV     AL,0                ;Scroll full screen
  97.             MOV     BH,7                ;Normal white on black
  98.             MOV     CX,0                ;Upper left corner of screen
  99.             MOV     DH,24               ;Bottom right
  100.             MOV     DL,79
  101.             INT     10h
  102.  
  103.             MOV     DX,0                ;Upper left corner of screen
  104.             MOV     BH,0                ;Assume page 0
  105.             MOV     AH,2                ;Set cursor position
  106.             INT     10h
  107.             RET
  108. Cls         ENDP
  109.  
  110. ; The following routine displays the directory pointed to by DS:DX
  111.  
  112. ShowDir     PROC    USES AX BX CX DX SI ES
  113.             MOV     AH,2Fh              ;Determine DTA
  114.             INT     21h
  115.             ADD     BX,1Eh              ;Point to ASCIIZ filename field
  116.  
  117.             MOV     AH,4Eh              ;Find first
  118.             MOV     CX,37h              ;Show all except volume label
  119.             INT     21h
  120.             JC      Done
  121. SDLoop:     CALL    ShowName            ;Print file name
  122.             MOV     AH,4Fh              ;Find next
  123.             INT     21h
  124.             JNC     SDLoop
  125. Done:       MOV     SI,OFFSET NoMore
  126.             CALL    PrtString
  127.             RET
  128. ShowDir     ENDP
  129.  
  130. ; Print ASCIIZ file name pointed to by ES:BX
  131.  
  132. ShowName    PROC    USES SI
  133.             PUSH    DS                  ;Save for later
  134.             PUSH    ES                  ;Set up addressing
  135.             POP     DS
  136.             MOV     SI,BX
  137.             CALL    PrtString
  138.             POP     DS
  139.             MOV     SI,OFFSET CRLF
  140.             CALL    PrtString
  141.             RET
  142. ShowName    ENDP
  143.  
  144. ; Force drive to be assumed as A:
  145.  
  146. MakeItA     PROC    USES AX BX
  147.             MOV     AH,44h              ;IOCTL
  148.             MOV     AL,0Fh              ;Set logical drive map
  149.             MOV     BL,1                ;Drive A:
  150.             INT     21h
  151.             RET
  152. MakeItA     ENDP
  153.  
  154. ; Force drive to be assumed as B:
  155.  
  156. MakeItB     PROC    USES AX BX
  157.             MOV     AH,44h              ;IOCTL
  158.             MOV     AL,0Fh              ;Set logical drive map
  159.             MOV     BL,2                ;Drive A:
  160.             INT     21h
  161.             RET
  162. MakeItB     ENDP
  163.  
  164. ; The following routine prints the ASCIIZ string pointed to by DS:SI
  165. ; DOS routines for character output are used
  166.  
  167. PrtString   PROC    USES AX DX SI
  168. PS1:        MOV     DL,[SI]             ;Get character
  169.             INC     SI                  ;Point to next one
  170.             CMP     DL,0                ;End of string?
  171.             JE      PS2                 ;Yes, so exit
  172.             MOV     AH,02h              ;Output a character
  173.             INT     21h
  174.             JMP     PS1                 ;Keep doing it
  175. PS2:        RET
  176. PrtString   ENDP
  177.  
  178. ; The following routine prints the message pointed to by SI and then
  179. ; waits for a keypress
  180.  
  181. KeyMsg      PROC    USES AX
  182.             CALL    PrtString           ;Message pointed to by SI
  183.             MOV     AH,0                ;Read keyboard character
  184.             INT     16h
  185.             RET
  186. KeyMsg      ENDP
  187.  
  188.             END
  189.